home *** CD-ROM | disk | FTP | other *** search
/ Best of www.BestZips.com (Collector's Edition) / Best of WWW.BESTZIPS.COM Collector's Edition (JCSM Shareware) (JCS Marketing).ISO / tutorial / adatu311.zip / CHANGESN.ADA < prev    next >
Text File  |  1996-01-10  |  3KB  |  57 lines

  1. -- CHANGESN.ADA   Ver. 3.11   10-JAN-1996   Copyright 1988-1996 John J. Herro
  2. --
  3. -- SOFTWARE INNOVATIONS TECHNOLOGY          http://members.aol.com/AdaTutor
  4. -- 1083 MANDARIN DR NE                      ftp://members.aol.com/AdaTutor
  5. -- PALM BAY FL 32905-4706
  6. --                                          johnherro@aol.com
  7. -- (407) 951-0233                           john.herro%374-38-2@satlink.oau.org
  8. --
  9. -- Used to change the serial number in ADA_TUTR.DAT after registering.
  10. --
  11.  
  12. with Text_IO, Direct_IO; use Text_IO;
  13. procedure ChangeSN is
  14.    subtype Block_Subtype is String(1 .. 64);
  15.    package Random_IO is new Direct_IO(Block_Subtype); use Random_IO;
  16.    Data_File_Name : constant String := "ADA_TUTR.DAT";
  17.    Data_File      : Random_IO.File_Type;
  18.    Block          : Block_Subtype;            -- Block read from the data file.
  19.    Block_Num      : Random_IO.Count := 40;      -- Number of the current block.
  20.    Place          : Integer;                 -- Index to search for "Serial #".
  21.    Found          : Boolean := False;         -- True when "Serial #" is found.
  22.    Serial_Num     : String(1 .. 5);             -- The serial number, in ASCII.
  23.    Input          : String(1 .. 6);                     -- Input that you type.
  24.    Len            : Integer;                          -- Length of typed input.
  25.    Legal_Note     : constant String := " Copyright 1988-96 John J. Herro ";
  26.                        -- Legal_Note isn't used by the program, but it causes
  27.                        -- most compilers to place this string in the .EXE file.
  28. begin
  29.    Random_IO.Open(Data_File, Mode => Inout_File, Name => Data_File_Name);
  30.    while not Found loop
  31.       Block_Num := Block_Num + 1;
  32.       Read(File => Data_File, Item => Block, From => Block_Num);
  33.       Place := 0;
  34.       while not Found and Place <= 50 loop
  35.          Place := Place + 1;
  36.          Found := Block(Place .. Place + 7) = "Serial #";
  37.       end loop;
  38.    end loop;
  39.    Serial_Num := Block(Place + 10 .. Place + 14);
  40.    Put_Line("Old serial number is " & Serial_Num & ".");
  41.    Put("New serial number:   ");
  42.    Input := Serial_Num & " ";
  43.    Get_Line(Input, Len);
  44.    New_Line;
  45.    Block(Place + 10 .. Place + 14) := Input(1 .. 5);
  46.    Write(File => Data_File, Item => Block, To => Block_Num);
  47.    Close(Data_File);
  48.    Put_Line("Serial number changed to " & Input(1 .. 5) & ".");
  49. exception
  50.    when Random_IO.Name_Error =>
  51.       Put("I'm sorry.  The file " & Data_File_Name);
  52.       Put_Line(" seems to be missing.");
  53.    when Random_IO.End_Error =>
  54.       Put("I'm sorry.  I couldn't find a serial number in ");
  55.       Put_Line(Data_File_Name & ".");
  56. end ChangeSN;
  57.